package office.service.business.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import office.action.business.form.GoodsOrderDetailConditionForm;
import office.action.business.wrapper.GoodsOrderDetailWrapper;
import office.bo.business.impl.GoodsOrderDetail;
import office.domainset.BizDomainProviderSetImpl;
import office.service.business.IGoodsOrderDetailService;
import platform.common.dao.IDomainProvider;
import platform.common.exception.BusinessException;
import platform.common.service.impl.BaseBizServiceImpl;
import platform.util.Util;

public class GoodsOrderDetailServiceImpl extends BaseBizServiceImpl implements IGoodsOrderDetailService{
	@Override
	public List<GoodsOrderDetailWrapper> findAllGoodsOrderDetailByGoodsOrderId(
			GoodsOrderDetailConditionForm condition) throws BusinessException {
		List<GoodsOrderDetailWrapper> wrapperList = new ArrayList();
		try{
			BizDomainProviderSetImpl domainProviderSetImpl=(BizDomainProviderSetImpl)domainProviderSet;
			IDomainProvider provider = domainProviderSetImpl.getGoodsOrderDetailDP();
			Map condMap= new HashMap();
			if(null!=condition&&!Util.isNull(condition)){
				condMap.put("goodsOrderId", condition.getGoodsOrderId());
			}
			List list = domainProviderSetImpl.getDao().findByDynamicHql(provider,"findGoodsOrderDetailByGoodsOrderId",condMap,new HashMap());
			GoodsOrderDetailWrapper wrapper;
			for(int i=0;i<list.size();i++){
				GoodsOrderDetail bo = (GoodsOrderDetail)list.get(i);
				wrapper = new GoodsOrderDetailWrapper();
				wrapper.copyToWrapper(bo);
				wrapperList.add(wrapper);
			}
		}catch (Exception e) {
			log.error("", e);
			throw this.handleBusinessServiceException("根据合同获取订单列表失败！", e);
		}
		return wrapperList;
	}
}
